/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ihmproject.voletEdition;

import java.io.IOException;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.NotifyDescriptor.Confirmation;
import org.openide.cookies.SaveCookie;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.CookieSet;
import org.openide.windows.Mode;
import org.openide.windows.WindowManager;

/**
 *
 * @author sebastien
 */
public class MyNode extends AbstractNode {

    DeleteCookieImpl impl;
    AddCookieImpl ajout;

    public MyNode() {
        super(Children.LEAF);
        impl = new DeleteCookieImpl();
        ajout = new AddCookieImpl();
    }
    
    public CookieSet getCookieSetNode() {
        return super.getCookieSet();
    }

    public void fire(boolean modified) {
        if (modified) {
            getCookieSet().assign(DeleteCookieImpl.class, impl);
            getCookieSet().assign(AddCookieImpl.class, ajout);
        } else {
            getCookieSet().assign(DeleteCookieImpl.class);
            getCookieSet().assign(AddCookieImpl.class);
        }
    }

    public class DeleteCookieImpl implements SaveCookie{

        public void save() throws IOException {

            Confirmation msg = new NotifyDescriptor.Confirmation("Voulez vous supprimer cette tâche ?", "Confirmation", NotifyDescriptor.OK_CANCEL_OPTION,
                NotifyDescriptor.QUESTION_MESSAGE);

            Object result = DialogDisplayer.getDefault().notify(msg);

            if (NotifyDescriptor.YES_OPTION.equals(result)) {
                fire(false);
                
            }

        }
    }

    public class AddCookieImpl implements SaveCookie{

        public void save() throws IOException {


        }
    }
}
